﻿using System;
using System.Collections.Generic;
using System.Text;
using ImPM.Data.BusinessObjects;
using ImPM.Data.ManagerObjects;
using ImPM.Data.UnitTests;


namespace ImPM.Demo
{
    public class Program
    {
        static void Main(string[] args)
        {
            //IManagerFactory managerfactory = new ManagerFactory();
            //IProjectManager projectmanager = managerfactory.GetProjectManager();

         
            //Project proj = projectmanager.GetByCriteria(
            //if (resource == null)
            //    throw new NullReferenceException();

            //Console.Out.WriteLine("Existing values: {0}, {1}", resource.Id, resource.ResourceName);
            Console.Out.WriteLine("Creating a Project...");
            //Console.In.ReadLine();
            //Console.Out.WriteLine(DateTime.Now.ToLongTimeString());
           
            //Console.Out.WriteLine(DateTime.Now.ToLongTimeString());
            //Console.In.ReadLine();

            IProjectManager manager;
            
            IManagerFactory managerFactory = new ManagerFactory(); 
            manager = managerFactory.GetProjectManager();

            Project proj = new Project();
            proj.ProjectName = "Primeiro Projeto1";
            proj.StartDate = DateTime.Now.Date;
            proj.FinishDate = DateTime.Now.AddDays(5.0);
            object obj = manager.Save(proj);
            Console.WriteLine(obj.ToString());

            Project proj2 = manager.GetById(1);
            Console.WriteLine(proj2.ProjectName);
            Console.ReadLine();
        }
          

    }

    public class Test
    {
        protected  IProjectManager manager;

        Test()
        {
            IManagerFactory managerFactory = new ManagerFactory(); 
            manager = managerFactory.GetProjectManager();

        }

        public bool CreateProject()
        {
            Project proj = new Project();
            proj.ProjectName = "Primeiro Projeto";
            proj.StartDate = DateTime.Now.Date;
            proj.FinishDate = DateTime.Now.AddDays(5.0);
            manager.Save(proj);
            return true;
 
        }

        protected Project GetFirstProject()
        {
            IList<Project> entityList = manager.GetAll(1);
            if (entityList.Count == 0)
                Console.WriteLine("All tables must have at least one row for unit tests to succeed.");
            return entityList[0];
        }

 
    }
}
